<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>首页 </title>
    <link rel="icon" href="favicon.ico" type="image/ico">
    <link href="css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}" rel="stylesheet">
    <link href="css/materialdesignicons.min.css"  th:href="@{/css/materialdesignicons.min.css}" rel="stylesheet">
    <link href="css/style.min.css" th:href="@{/css/style.min.css}" rel="stylesheet"></head>

<body>
<div class="lyear-layout-web" id="mainContent">


    <div  th:if="${session.grade} eq 3">
        <div th:replace="~{main::rightbar}"></div>
    </div>
    <div  th:if="${session.grade} eq 4">
        <div th:replace="~{adminmain::adminrightbar}"></div>
    </div>
    <div class="lyear-layout-container">

        <header class="lyear-layout-header" th:fragment="topbar">

            <nav class="navbar navbar-default">
                <div class="topbar">

                    <div class="topbar-left">
                        <div class="lyear-aside-toggler">
                            <span class="lyear-toggler-bar"></span>
                            <span class="lyear-toggler-bar"></span>
                            <span class="lyear-toggler-bar"></span>
                        </div>
                        <span class="navbar-page-title"> 文件管理 </span>
                    </div>
                    <div th:replace="~{main::bar}"></div>


                </div>
            </nav>

        </header>

        <main class="lyear-layout-content">


            <div class="container-fluid">



                <div class="row">

                    <div class="col-lg-12">
                        <div class="card">
                            <div class="card-header">
                                <h4>文件审核</h4>
                            </div>
                            <div class="card-body">
                                <div class="table-responsive">
                                    <table class="table table-hover" >
                                        <thead>
                                        <tr>
                                            <th>文件名</th>
                                            <th>上传时间</th>
                                            <th>上传者</th>
                                            <th>文件描述</th>
                                            <th>下载</th>
                                            <th>审核</th>
                                        </tr>
                                        </thead>
                                        <tbody id="boby">
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>

            </div>

        </main>
        <!--End 页面主要内容-->

    </div>
</div>

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="js/main.min.js"></script>

<!--图表插件-->
<script type="text/javascript" src="js/Chart.js"></script>

<script type="text/javascript">
    //别忘了导入该用的js文件
    function sherror(id) {
        console.log(id)
        var why;
        why=prompt("请输入退回原因?");
        var data1={"why":why};

        console.log(data1);
        $.ajax({
            type:'post',
            url:'/shenhe/'+id,
            contentType: "application/json",
            datatype:"JSON",
            // data:user,
            //contentType:'application/json;charset=UTF-8',
            data:JSON.stringify(data1),
            async : true,
            // global:false,
            success:function(json){
                alert('操作成功');
                subForm();

            },
            error: function (data) {
               alert('操作失败');
            },
        });
    } function shesuccess(id) {
        console.log(id)
        $.ajax({
            type:'get',
            url:'/shenhe/'+id,
            contentType: "application/json",
            async : true,
            // global:false,
            success:function(json){
                alert('操作成功');
                subForm();

            },
            error: function (data) {
                alert('操作失败');
                subForm();
            },
        });}

    subForm();
    function subForm() {

        $.ajax({

            url: '/shfilelist', //请求的url
            type: 'get', //请求的方式
            //form表单里要提交的内容，里面的input等写上name就会提交，这是序列化
            cache : false,
            async : true,
            error:function (data) {
                alert('请求失败');
            },
            success:function (data) {
                console.log(data)
                var str1 = "";
                //清空table中的html
                $("#boby").html("");
                for(var i = 0;i<data.length;i++){
                    console.log(data)
                    str1 = "<tr>" +
                        "<td>"+data[i].name + "</td>" +
                        "<td>"+data[i].up + "</td>" +
                        "<td>"+data[i].upname + "</td>" +
                        "<td>"+data[i].miaoshu + "</td>" +
                        "<td>"+"<a href='/down/"+data[i].id+"'"+"style=' height: 21px;\n" +
                        "            line-height: 21px;\n" +
                        "            padding: 0 11px;\n" +
                        "            background-color: #33cabb;\n" +
                        "           border-color: #33cabb;\n" +
                        "            color: #fff!important;\n" +
                        "            border-radius: 3px;\n" +
                        "            display: inline-block;\n" +
                        "            text-decoration: none;\n" +
                        "            font-size: 12px;\n" +
                        "            outline: none;'>下载</a>"+"</td>" +
                        "<td>"+" <div class=\"btn-group\">\n" +
                        "                            <a class=\"btn btn-xs btn-default\" onclick='shesuccess("+data[i].id+")'"+"title=\"通过\" data-toggle=\"tooltip\"><i class=\"mdi mdi-pencil\"></i></a>\n" +
                        "                            <a class=\"btn btn-xs btn-default\"  onclick='sherror("+data[i].id+")' title=\"退回\" data-toggle=\"tooltip\"><i class=\"mdi mdi-window-close\"></i></a>\n" +
                        "                          </div>"+"</td>" +

                        "</tr>";
                    $("#boby").append(str1);
                }
            }
        });
    }
    function down(id){

        $.ajax({
            type:'get',
            url:'/down/'+id,
            // data:user,
            //contentType:'application/json;charset=UTF-8',

            async : true,
            // global:false,
            success:function(json){
                //alert('删除成功');
                ajaxFileDownload(data.boby, data.filename);
            },
            error: function (data) {
               // alert('删除失败');
            },
        });


    }
    function auditing(id){

        $.ajax({
            type:'get',
            url:'/fileauditing/'+id,
            // data:user,
            //contentType:'application/json;charset=UTF-8',

            async : true,
            // global:false,
            success:function(json){
                alert('操作成功');

            },
            error: function (data) {
                alert('删除失败');
            },
        });


    }

</script>
</body>

</html>